import { MockMethod } from 'vite-plugin-mock';
import { resultPageSuccess, resultSuccess } from '../_util';

const demoList = (() => {
  const result: any[] = [];
  for (let index = 0; index < 30; index++) {
    result.push({
      id: `${index}`,
      billNumber: '@string(lower,10)',
      'billType|1': ['变更单', '归还单', '转移单', '报废单', '盘点单', '领用单'],
      'billState|1': ['审核', '草稿', '驳回'],
      operationNumber: '@integer(1, 50)',
    });
  }
  return result;
})();
//这是待办事项统计mock数据
const countData = [
  { type: '入库单', count: '@integer(1, 10)' },
  { type: '领用/借用单', count: '@integer(1, 10)' },
  { type: '归还单', count: '@integer(1, 10)' },
  { type: '转移单', count: '@integer(1, 10)' },
  { type: '变更单', count: '@integer(1, 10)' },
  { type: '报废单', count: '@integer(1, 10)' },
  { type: '维护单', count: '@integer(1, 10)' },
  { type: '盘点单', count: '@integer(1, 10)' },
];
//这是待办事项统计饼图mock数据
const countPie = [
  {
    name: '驳回',
    value: 6,
    itemStyle: {
      color: '#eef10c',
    },
  },
  {
    name: '草稿',
    value: 2,
    itemStyle: {
      color: '#0cb0f1',
    },
  },
  {
    name: '审核',
    value: 9,
    itemStyle: {
      color: '#0ce9f1',
    },
  },
  {
    name: '结束',
    value: 30,
    itemStyle: {
      color: '#36e036',
    },
  },
];

enum Api {
  todolist = '/dashboard/getTodolist',
  count = '/todo-list/pendingcount',
  countPie = '/distribution-chart/distributioncount',
}
const prefix = '/jeecgboot';
export default [
  {
    url: prefix + Api.todolist,
    timeout: 1000,
    method: 'get',
    response: ({ query }) => {
      const { page = 1, pageSize = 20 } = query;
      return resultPageSuccess(page, pageSize, demoList);
    },
  },
  //这是待办事项统计接口
  {
    url: prefix + Api.count,
    timeout: 1000,
    method: 'get',
    response: ({ query }) => {
      const { page = 1, pageSize = 20 } = query;
      return resultPageSuccess(page, pageSize, countData);
    },
  },
  //这是分布图接口
  {
    url: prefix + Api.countPie,
    timeout: 1000,
    method: 'get',
    response: ({ query }) => {
      const { page = 1, pageSize = 20 } = query;
      return resultPageSuccess(page, pageSize, countPie);
    },
  },
] as MockMethod[];
